package com.xiyou.luckdraw.common.constants;

/**
 * @ClassName: SysRetCodeConstants
 * @Description: 统一返回码
 * @author: limingxing
 * @Date: 2019-10-08 21:15
 */

public enum ResultCodeConstants {

    // 系统公用
    SUCCESS(200, "成功"),
    PARAM_ERROR(201, "参数错误"),
    API_ERROR(202, "接口错误"),
    ERROR(204, "未知错误"),
    BUSINESS_ERROR(300, "业务异常"),
    DATA_INVALID(207, "数据无效"),
    THIRD_API_ERROR(212, "请求第三方接口出错"),
    DATA_NOT_EXISTS(213, "数据不存在"),
    REQUEST_CHECK_FAILURE(215, "请求数据校验失败"),
    SYSTEM_ERROR                        (3099, "系统错误"),
    REQUISITE_PARAMETER_NOT_EXIST       (3073, "必要的参数不能为空"),
    DATA_NOT_EXIST                      (3070, "数据不存在"),;


/*    USERORPASSWORD_ERRROR               ("003001","用户名或密码不正确"),
    TOKEN_VALID_FAILED                  ("003002","token校验失败"),
    USERNAME_ALREADY_EXISTS             ("003003","用户名已存在"),
    USER_REGISTER_FAILED                ("003004","注册失败，请联系管理员"),
    KAPTCHA_CODE_ERROR                  ("003005","验证码不正确"),

    REQUEST_FORMAT_ILLEGAL              ("003060", "请求数据格式非法"),
    REQUEST_IP_ILLEGAL                  ("003061", "请求IP非法"),
    REQUEST_CHECK_FAILURE               ("003062", "请求数据校验失败"),
    DATA_NOT_EXIST                      ("003070", "数据不存在"),
    DATA_REPEATED                       ("003071", "数据重复"),
    REQUEST_DATA_NOT_EXIST              ("003072", "传入对象不能为空"),
    REQUEST_DATA_ERROR                  ("003074", "必要的参数不正确"),
    PERMISSION_DENIED                   ("003091", "权限不足"),
    DB_EXCEPTION                        ("003097", "数据库异常"),
    SYSTEM_TIMEOUT                      ("003098", "系统超时"),
    PIPELINE_RUN_EXCEPTION              ("005094","系统异常"),
    DB_SAVE_EXCEPTION                   ("005096","数据保存异常");*/


    private Integer code;
    private String message;

    ResultCodeConstants(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public Integer getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(Integer code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (ResultCodeConstants s : ResultCodeConstants.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
